﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ListenerDemo : MonoBehaviour {

	void Start () {
        VIPEventListener.AddListener(VIPEventCode.Print, Print);
        VIPEventListener.AddListener<string>(VIPEventCode.CustomPrint, CustomPrint);
        VIPEventListener.TriggleListener(VIPEventCode.Print);
        VIPEventListener.TriggleListener(VIPEventCode.CustomPrint,"通过监听传值执行打印");
    }

    private void OnDestroy()
    {
        //一定要在这里面销毁对应的监听
        VIPEventListener.RemoveListener(VIPEventCode.Print, Print);
        VIPEventListener.RemoveListener<string>(VIPEventCode.CustomPrint, CustomPrint);
    }

    private void Print() {
        print("通过监听执行");
    }

    private void CustomPrint(string str) {
        print(str);
    }

}
